The Traversable Typeclass
Traversable is the typeclass for data structures that can be traversed from left to right while performing an effect, and then rebuilt with the same structure.
class (Functor t, Foldable t) => Traversable t where
traverse :: Applicative f => (a -> f b) -> t a -> f (t b)
sequenceA :: Applicative f => t (f a) -> f (t a)
mapM :: Monad m => (a -> m b) -> t a -> m (t b)
sequence :: Monad m => t (m a) -> m (t a)
{-# MINIMAL traverse | sequenceA #-}
The illustration is to apply an effectful function to every element, combine all effects, and reconstruct the original container.